import { dataSource } from '../config/database';
import { orderEntity } from '../entity/Order.entity';
import Result from '../vo/result';
import { runConsumer } from '../config/kafkaConfig';
import logger from '../Logger/logger';
import { ResultCode } from '../enums/resultCode';

const tableRepository = dataSource.getRepository(orderEntity);

export const createOrderService = async (orderId: string) => {
  try {
    await tableRepository.save({
      orderId: orderId,
    });
    return Result.success('订单创建成功');
  } catch (err) {
    logger.error('订单创建失败', err);
    return Result.fail(ResultCode.FAIL, '订单创建失败');
  }
};
